package com.nwpu.coursesupport.controller;

import com.nwpu.coursesupport.entity.ForumModule;
import com.nwpu.coursesupport.entity.ForumPost;
import com.nwpu.coursesupport.mapper.ForumModuleMapper;
import com.nwpu.coursesupport.mapper.ForumPostMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class ForumModuleController extends AbstractController{
	
	@Autowired
	private ForumPostMapper forumPostMapper;

	@RequestMapping("/forumModule")
	public String list(@RequestParam("moduleId")Integer moduleId, Model model){
		List<ForumPost> forumPosts = forumPostMapper.selectByExample(null);//

		model.addAttribute("forumPosts",forumPosts);
		return "/teapage/forum-module-index";
	}
	@RequestMapping("/createPost")
	public String createModule(ForumPost ForumPost){
		forumPostMapper.insert(ForumPost);
		return "redirect:/forumModule";
	}

}
